<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.ionglobal.db.*" %>
<%@ page import="com.ionglobal.lib.*" %>
<%@ page import="com.ionglobal.misc.*" %>

<%@ include file="../init_include.jsp" %>
<%
	Sysop sysop=(Sysop)session.getAttribute("sysop");
	if ( sysop==null)
	{
		response.sendRedirect("../index.jsp");
		return;
	}	
		
	String relativePath=request.getParameter("path");
	String module=request.getParameter("module");
	String fileRoot=SysEnv.get("web.fileRoot");
	String rootUrl=SysEnv.get("web.fileUrl");
 	String Systemcharset=SysEnv.get("SYSTEM.CharSet").trim();
 	String Languagecharset=SysEnv.get("LANGUAGE.CharSet").trim();	
	String fn=request.getParameter("ra");
	String content=request.getParameter("content");
	
	String completePath;
	if ( relativePath==null) relativePath="";
	String rstPath=relativePath;
	while (relativePath.indexOf("../")!=-1)
	relativePath=Utilities.strReplace(relativePath,"../","");
	
	while (fileRoot.endsWith("\\")||fileRoot.endsWith("/"))
	fileRoot=fileRoot.substring(0,fileRoot.length()-1);
	if (fileRoot.length()<1) fileRoot="/";
	
	
	completePath=fileRoot+File.separator+relativePath;
	
	
	File path=new File(completePath);
	File src=null;
	File dst=null;
	
	if (fn!=null) src=new File(path,fn);
	 
   	PrintWriter pw=
 	new PrintWriter( new BufferedWriter
 						(	new OutputStreamWriter
		 					(
		 						new FileOutputStream(src),Systemcharset
		 					)
 					 	)
 					);
 	pw.print(content);
	
	pw.close();
%>	

<HTML>
<HEAD>
<META HTTP-EQUIV="REFRESH" CONTENT="2; URL=<% out.print("fileManage.jsp?path="+rstPath);%>">
<link rel="stylesheet" href="../css.css" type="text/css">>
</HEAD>
<body>
<%=Language.getNameByCode("fms.save.success","Save opertion is successful!")%>
</body>
</html>
<%@ include file="../init_free.jsp" %>